<!DOCTYPE htmlPUBLIC "-//W3C//DTDXHTML1.0Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><title>HelloWorld RFC4627 JSON-RPC test based on JavaScript</title>
  <script type="text/javascript" src="/js/prototype.js"></script>
  <script type="text/javascript" src="/js/json.js"></script>
  <script type="text/javascript" src="/js/jsonrpc.js"></script>
</head>
<body>
<h1>HelloWorld RFC4627 JSON-RPC test based on JavaScript</h1>

<div id="container"><p>This is an example</p></div>

<script type="text/javascript">
  //<![CDATA[
  function log(result, error) {
    if(!error){
      $("container").update(JSON.stringify(result) + "\n");
    }else{
      $("container").update("ERROR <pre>"+JSON.stringify(result).replace(/(\\n)+/g, "<br/>") + "</pre>\n");  
    }
  }
  function testMain(name) {
    var testService = new JsonRpcTransaction("/json_rpc/current_date", "current_date_proc", [name]);
    testService.addCallback(log);
    testService.addErrorCallback(log);
    //testService.sendRequest();
  }
  //]]>
</script>

<form action="index.html" onsubmit="testMain($(name).value); return false">
  What is your name?
  <input id="name" type="text" size="10" value="&#280;dward &#260;cki"/>
  &nbsp;<span style="font-size:x-small;">press enter</span>
</form>

<script type="text/javascript">
  Field.focus($("name"));
</script>
</body>
</html>